package com.tt.dp.component;

import java.util.Iterator;

public class Waitress {

    private MenuComponent allMenus;

    public Waitress(MenuComponent allMenus) {
        this.allMenus = allMenus;
    }

    public void printMenu(){
        allMenus.print();
    }

    public void printVegetarianMenu(){
        Iterator it = allMenus.createIterator();

        System.out.println("\nVEGETARIAN MENU\n----");

        while (it.hasNext()) {

            MenuComponent item = (MenuComponent)it.next();

            try{
                if(item.isVegetarian()){
                    item.print();
                }
            }catch (UnsupportedOperationException ex){}
        }
    }
}
